#coding=UTF-8
# -*- coding: utf-8 -*- 
'''
Created on 2012-5-16

@author: eoe2005
'''
from google.appengine.ext import db
##页面相关信息
class T_Page(db.Model):
    #页面名在
    Fname = db.StringProperty(required = True)
    #页面显示的标题
    Ftitle = db.StringProperty()
    #页面的地址
    Faction = db.StringListProperty(required = True)
    #是否打开
    Fopen = db.BooleanProperty()
    #seokey
    Fkeys = db.StringProperty()
    #seo 描述
    Fdesc = db.StringProperty()
    #页面要加载的样式文件
    Fcss = db.StringProperty()    
#插件相关的信息
class T_Widget(db.Model):
    #插件名字
    Fname = db.StringProperty(required = True)
    #是否开启了
    Fopen = db.BooleanProperty()
#页面上的位置信息
class T_Zone(db.Model):
    #页面可以划分的区域
    Fzone = db.StringProperty(required = True)
    Fcss = db.StringProperty()
#页面的样式表配置
class T_Css(db.Model):
    #样式表的名字
    Fname = db.StringProperty(required = True)
    #样式表描述
    Fdesc = db.StringProperty()
    #样式表是否打开
    Fopen = db.BooleanProperty()
#样式表的配置值
class T_Css_Content(db.Model):
    #样式表的名字
    Fcss = db.StringProperty(required = True)
    #样式的名字
    Fname = db.StringProperty(required = True)
    #描述
    Fdesc = db.StringProperty()
    #样式的内容
    Fbody = db.StringProperty(required = True)
##页面的布局信息
class T_Page_Zone(db.Model):
    #页面名字
    Fpage = db.StringProperty(required = True)
    #取悦名字
    Fzone = db.StringProperty(required = True)
    #顺序
    Findex = db.IntegerProperty()
class T_Page_Widget(db.Model):
    ##页面中插件的配置新
    #页面的属性
    Fpage = db.StringProperty(required = True)
    #插件的名字
    Fwidget = db.StringProperty(required = True)
    #要显示的区域
    Fzone = db.StringProperty(required = True)
    #显示顺序
    Findex = db.IntegerProperty()

##根据页面的名字获取页面的信息
def getPage(pagename):
    q = db.GqlQuery("SELECT * FROM T_Page WHERE Fname=:1",pagename)
    result = q.fetch(1)
    for r in result:
        return r
    return None  
#获取页面的区域列表
def getPageZone(pagename):
    q = db.GqlQuery("SELECT Fzone,Findex FROM T_Page_Zone WHERE Fpage=:1 ORDER BY Findex ASC",pagename)
    return q.fetch(100)
#获取页面的区域信息
def getZone(pagename):
    pagezones = getPageZone(pagename)
    names = ""
    for row in pagezones:
        names += "," + row.Fzone
    q = db.GqlQuery("SELECT * FROM T_Zone WHERE Fzone IN(:1)",names)
    return q.fetch(1000)





















